This method relies on the fact that music is periodic (repeats in time) wheras vocals are relativly aperiodic. Fourier transforms transform data from time space to frequency space. The fourier transform for a simple sine wave is shown below
Major limitation is that some vocal frequencies are periodic and some musical frequencies are aperiodic, so there is some leakage between files and perfect separation cant be obtained with this method. Need machine learning techniques for further separation.
from main import main
import IPython
main('sounds/oasis.wav', 2, 10)
IPython.display.display(IPython.display.Audio("bg.wav"))
IPython.display.display(IPython.display.Audio("fg.wav"))
Time elapsed 0.48108434677124023 sounds/oasis.wav
main('sounds/otherside.wav', 2, 10)
IPython.display.display(IPython.display.Audio("bg.wav"))
IPython.display.display(IPython.display.Audio("fg.wav"))
Time elapsed 0.48308444023132324 sounds/otherside.wav
main('sounds/queen.wav', 2, 10)
IPython.display.display(IPython.display.Audio("bg.wav"))
IPython.display.display(IPython.display.Audio("fg.wav"))
Time elapsed 0.49858808517456055 sounds/queen.wav